package com.ecommerce.product.domain;

import com.ecommerce.product.enums.ProductType;
import org.springframework.stereotype.Component;

@Component
public class IndexNameResolver {

    private static final String INDEX_PREFIX = "product_";
    private static final String DEFAULT_INDEX = "product_standard";

    public String resolveIndexName(ProductDocument document) {
        return resolveIndexName(document.getProductType());
    }
    
    /**
     * 根据商品类型解析索引名
     */
    public String resolveIndexName(ProductType type) {
        if (type == null) {
            return DEFAULT_INDEX;
        }
        return INDEX_PREFIX + type.name().toLowerCase();
    }
}